package edu.java.homework.hw03.ipj05;

public class J03 {

    /**
     * @param args
     */
    public static void main(String[] args) {
	// int[] arr= { 1, 2, 3, 4, 5, 2, 3, 5, 10, 21, 1, 3, 2, 15 };
	int[] arr = { 12, 12, 10, 7, 5, 3, 2, 2, 0, -12, -19 };
	// int[] arr=null;
	System.out.println("DescendingOrderInTheArray? : "
		+ isDescendingArray(arr));
    }

    /**
     * Check if descending order is applied on the array's elements
     * 
     * @param array
     * @return boolean
     * @throws IllegalArgumentException
     *             the array must be not null pointed
     */
    public static boolean isDescendingArray(int[] array) {
	if (array == null) {
	    throw new IllegalArgumentException(
		    "The array is null pointed.Incorrect input.");
	}
	for (int index = 0; index <= array.length - 2; index++) {
	    if (array[index] < array[index + 1]) {
		return false;
	    }
	}
	return true;
    }
}
